# ============================================================================
# 最简GPU测试 - 检查GPU是否能运行
# ============================================================================

wipe
puts "=== 最简GPU测试 ==="

model basic -ndm 2 -ndf 2

# 2个节点，1个单元
node 1  0.0  0.0
node 2  1.0  0.0

# 简单弹性材料
uniaxialMaterial Elastic 1  200.0e9

puts "材料: E=200GPa"

# 边界条件：节点1完全固定，节点2仅Y方向固定（避免刚体运动）
fix 1  1  1
fix 2  0  1

# 单个Truss单元
element truss 1  1  2  0.01  1

puts "创建Truss单元"

# 施加水平力
pattern Plain 1 Linear {
    load 2  1000.0  0.0
}

puts "\n=== CPU测试 ==="
constraints Plain
numberer Plain
system BandGeneral
test NormDispIncr 1.0e-8 10
algorithm Newton
integrator LoadControl 1.0
analysis Static

set ok [analyze 1]
if {$ok == 0} {
    puts "✓ CPU成功: 节点2位移 = [nodeDisp 2 1] m"
} else {
    puts "✗ CPU失败"
}

wipe

# 重建模型
model basic -ndm 2 -ndf 2
node 1  0.0  0.0
node 2  1.0  0.0
uniaxialMaterial Elastic 1  200.0e9
# 边界条件
fix 1  1  1
fix 2  0  1
element truss 1  1  2  0.01  1
pattern Plain 1 Linear {
    load 2  1000.0  0.0
}

puts "\n=== GPU测试 ==="
constraints Plain
numberer Plain
system GPUSolver
test NormDispIncr 1.0e-8 10
algorithm Newton
integrator LoadControl 1.0
analysis Static

puts "开始GPU分析..."
set ok [analyze 1]

if {$ok == 0} {
    puts "✓ GPU成功: 节点2位移 = [nodeDisp 2 1] m"
} else {
    puts "✗ GPU失败，错误代码: $ok"
}

puts "\n=== 测试完成 ==="
wipe
